package com.sixth.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sixth.core.entity.DictType;
import com.sixth.core.vo.R;
import com.sixth.system.service.DictTypeService;
import com.sixth.system.vo.DictTypeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 字典类型管理控制器
 *
 * @author Stu YH
 * @date Created in 2024/8/19 17:01
 * @description 提供字典类型管理相关的API接口
 */
@Api(tags = "字典类型管理")
@RestController
@RequestMapping("system/dictType")
public class DictTypeController {
    @Autowired
    private DictTypeService dictTypeService;

    /**
     * 分页查询字典类型数据列表
     * @param dictTypeVo 查询条件
     * @return 分页查询结果
     */
    @ApiOperation(value = "分页查询字典类型数据", notes = "根据查询条件分页查询字典类型数据")
    @PostMapping("/listByPage")
    public R<Page<DictType>> listByPage(@RequestBody DictTypeVo dictTypeVo) {
        return dictTypeService.selectByPage(dictTypeVo);
    }

    /**
     * 添加或更新字典类型
     * @param dictType 字典类型信息
     * @return 操作结果
     */
    @ApiOperation(value = "添加或更新字典类型", notes = "添加或更新字典类型信息")
    @PostMapping("/addUpdate")
    public boolean addUpdate(@RequestBody DictType dictType) {
        return dictTypeService.addUpdate(dictType);
    }

    /**
     * 批量删除字典类型
     * @param dictIds 需要删除的数据ID数组
     * @return 删除结果
     */
    @ApiOperation(value = "批量删除字典类型", notes = "根据ID数组批量删除字典类型")
    @GetMapping("/batchDelete/{dictIds}")
    public R batchDelete(@PathVariable Long[] dictIds) {
        return dictTypeService.batchDelete(dictIds);
    }
}
